#ifndef ACTOR3D_HPP
#define ACTOR3D_HPP
#include "Actor.hpp"
#include <QMap>
#include <QList>

struct Vertex {
    Vertex(float x=0.0f,float y=0.0f,float z=0.0f){
        v[0]=x;v[1]=y;v[2]=z;
    }
    float v[3];
};

class VertexList : public QList<Vertex> {
public:
    void*data() {
        int size = this->length()*3;
        float *d = new float[size];
        for(int i = 0; i<this->length(); i++) {
            d[(i*3)] = this->value(i).v[0];
            d[(i*3)+1] = this->value(i).v[1];
            d[(i*3)+2] = this->value(i).v[2];
        }
        return d;
    }
};

class Actor3D : public Actor
{
    Q_OBJECT;
public:
    Actor3D();

 public slots:
    // From Actor
    virtual void load();
    void update(float);

    virtual float getF(const QByteArray &key) const;
    virtual float& getF(const QByteArray &key);
    static bool keyValid(const QByteArray &key);
protected:
    QMap<QByteArray,float> values;

private:
    QList<QByteArray> scales, dims, derivs;
    VertexList *v_data,*v_colors,*v_normals;

    GLuint vboDataId,vboColorId,vboNormalId;
};

#endif // ACTOR3D_HPP
